﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BobcatWiiLib;

namespace Sample2_DraggingAndZooming
{
    /// <summary>
    /// This form shows an image which can be dragged around with an IR pen, or resized
    /// using two pens in an iPhone-style pinch-or-zoom way. The IR source handling is
    /// done with the BobcatWiiLib library.
    /// </summary><remarks>
    /// This sample uses the CalibratedIRManager directly. Other samples use the higher-level
    /// MultiTouchInputManager (MTIM). In most cases you will want to use the MTIM rather than
    /// the CalibratedIRManager directly. This sample demostrates using this slightly lower
    /// level in case you want to use it.
    /// </remarks>
    public partial class Form1 : Form
    {
        #region Public methods

        /// <summary>
        /// Constructor.
        /// </summary>
        public Form1()
        {
            InitializeComponent();
        }

        #endregion

        #region Private helper functions

        /// <summary>
        /// When the form is loaded we make sure that the IR sources are calibrated, and register 
        /// for IR events.
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // To set up the IR inputs we:
                // 1. Create the CalibratedIRManager. This is done here (in the try-catch block) as 
                //    it can throw exceptions if (for example) there are no wiimotes connected.
                //
                // 2. Load previously stored calibration data or show a calibration screen.
                CalibratedIRManager irManager = new CalibratedIRManager();
                irManager.loadCalibrationData("calibration_data.dat"); // this will show the calibration screen if the file doesn't exist.

                // We pass the IR manager to the two picture controls and set up the pictures
                // they show...
                picture1.loadImageFromFile("bobcat1.jpg");
                picture1.setCalibratedIRManager(irManager);

                picture2.loadImageFromFile("bobcat2.jpg");
                picture2.setCalibratedIRManager(irManager);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        #endregion

    }
}
